import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class DipSwitch here.
 * 
 * @author Christian Pérez Zavalija
 * @version 25-Jun-2013
 */
public class DipSwitch extends Device
{
    private GreenfootImage imgDipswitch;
    
    /**
     * Load the images in an array and displays the DipSwitch-8 and called to the constructor of the super class.
     */
    public DipSwitch()
    {
        super(16,12,55);
        imgDipswitch=new GreenfootImage("DipSwitch-8.png");
        setImage(imgDipswitch);
    }
    
    /**
     * The image is scale in 50%
     */
    public void scale()
    {
        imgDipswitch.scale(imgDipswitch.getWidth()-50,imgDipswitch.getHeight()-40);
    }
    
    /**
     * if you touch one of the pins with the dump, the pins are removed together with switches.
     */
    public void eliminate()
    {
        removeTouching(Pin.class);
        removeTouching(Switch.class);
    }
    
    /**
     * Checks if the input pin is connected and that pin has been clicked to call checkClickDS method of
     * the parent class.
     */
    public void act() 
    {
        super.act();
        if(pins[8].charge==1&&Greenfoot.mouseClicked(switches[0]))
            super.checkClickDS(0);
        if(pins[9].charge==1&&Greenfoot.mouseClicked(switches[1]))
            super.checkClickDS(1);
        if(pins[10].charge==1&&Greenfoot.mouseClicked(switches[2]))
            super.checkClickDS(2);
        if(pins[11].charge==1&&Greenfoot.mouseClicked(switches[3]))
            super.checkClickDS(3);
        if(pins[12].charge==1&&Greenfoot.mouseClicked(switches[4]))
            super.checkClickDS(4);
        if(pins[13].charge==1&&Greenfoot.mouseClicked(switches[5]))
            super.checkClickDS(5);
        if(pins[14].charge==1&&Greenfoot.mouseClicked(switches[6]))
            super.checkClickDS(6);
        if(pins[15].charge==1&&Greenfoot.mouseClicked(switches[7]))
            super.checkClickDS(7);
    }    
}
